const install = (Vue, vm) => {
  Vue.prototype.$t = {
    // 上传图片的api
    uploadUrl() {
      return "https://lzj.shandongweipai.com/api/repair/upload";
    },
    // 模态框
    modal(title, content, showCancel, confirmText, confirmColor, callback) {
      uni.showModal({
        title: title || "提示",
        content: content,
        showCancel: showCancel,
        cancelColor: "#666",
        confirmColor: confirmColor || "#389bf2",
        confirmText: confirmText || "确定",
        success(res) {
          if (res.confirm) {
            callback && callback(true)
          } else {
            callback && callback(false)
          };
        }
      });
    },
    // 是否登录
    goLogin() {
      this.modal("提示", "您还未登录，现在需要登录吗？", true, "登录", "", (res) => {
        if (res) {
          uni.navigateTo({
            url: "/pages/subpackages/mine/login/login",
          });
        } else {
          // uni.switchTab({
          //   url: "/pages/home/home",
          // });
        };
      });
    },
    // 权限
    goPower(type) {
      let url = "", content = "";
      if (type == 1)
        content = "请进行身份认证",
          url = "/pages/subpackages/mine/authen/identity";
      else if (type == 2)
        content = "请进行企业认证",
          url = "/pages/subpackages/mine/authen/company";
      else
        content = "请完善工作经历或教育经历",
          url = "/pages/subpackages/mine/resume/index";
      this.modal("提示", content, true, "确认", "", (res) => {
        if (res) {
          uni.navigateTo({
            url
          });
        }
      });
    },
    // 查看位置权限
    locationPower() {
      this.modal(
        "提示",
        "获取当前的地理位置，以便更好的服务您",
        false,
        "设置",
        "",
        () => {
          uni.openSetting({
            success: (res) => { },
          });
        }
      );
    }
  };
};

export default {
  install
};